var CryptoJS = require("crypto-js");

var base64ToHex = function (str) {
    const raw = atob(str);
    let result = '';
    for (let i = 0; i < raw.length; i++) {
        const hex = raw.charCodeAt(i).toString(16);
        result += (hex.length === 2 ? hex : '0' + hex);
    }
    return result.toLowerCase();
};

var iv = CryptoJS.enc.Hex.parse("abcdef9876543210abcdef9876543210");
window.ENC = function (a) {
    return CryptoJS.AES.encrypt(a, CryptoJS.enc.Hex.parse(base64ToHex(process.env.MIX_PUB_KEY.substr(7))), {
        iv: iv,
        padding: CryptoJS.pad.ZeroPadding,
    }).toString(CryptoJS.enc.base64);
};